package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.Log;
import com.itheima.domain.vo.PageBeanVo;
import com.itheima.mapper.LogMapper;
import com.itheima.mapper.UserInfoMapper;
import com.itheima.service.db.LogService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;


@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public void save(Log log) {
        //保存日志
        logMapper.insert(log);
    }


    //查询全部
    @Override
    public PageBeanVo logs(Integer page, Integer pagesize) {
        IPage<Log> page1 = new Page(page, pagesize);
        QueryWrapper<Log> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        page1 = logMapper.selectPage(page1, wrapper);


        return new PageBeanVo(page, pagesize, page1.getTotal(), page1.getRecords());
    }
}
